From cc3640b3fa65b83ce0071e4241223c28088bb70b Mon Sep 17 00:00:00 2001 From: "Karl O. Pinc kop@karlpinc.com" Date: Mon, 20 Jul 2026 22:53:45 +0000 Subject: [PATCH] Create, document, index, and trigger SUBADULT_ARRIVALS_LOG --- db/schemas/housekeeping/indexes/Makefile | 1 + .../indexes/create/subadult_arrivals_log.m4 | 31 +++++++ .../indexes/drop/subadult_arrivals_log.m4 | 26 ++++++ db/schemas/housekeeping/tables/Makefile | 1 + .../tables/create/subadult_arrivals_log.m4 | 34 +++++++ db/schemas/lib/triggers/Makefile | 3 +- .../triggers/create/subadult_arrivals_log.m4 | 49 ++++++++++ .../triggers/drop/subadult_arrivals_log.m4 | 23 +++++ doc/src/epilog.inc.m4 | 11 +++ doc/src/housekeeping.m4 | 1 + doc/src/housekeeping/subadult_arrivals_log.m4 | 92 +++++++++++++++++++ 11 files changed, 271 insertions(+), 1 deletion(-) create mode 100644 db/schemas/housekeeping/indexes/create/subadult_arrivals_log.m4 create mode 100644 db/schemas/housekeeping/indexes/drop/subadult_arrivals_log.m4 create mode 100644 db/schemas/housekeeping/tables/create/subadult_arrivals_log.m4 create mode 100644 db/schemas/lib/triggers/create/subadult_arrivals_log.m4 create mode 100644 db/schemas/lib/triggers/drop/subadult_arrivals_log.m4 create mode 100644 doc/src/housekeeping/subadult_arrivals_log.m4 diff --git a/db/schemas/housekeeping/indexes/Makefile b/db/schemas/housekeeping/indexes/Makefile index 67184df..9d1b2f1 100644 --- a/db/schemas/housekeeping/indexes/Makefile +++ b/db/schemas/housekeeping/indexes/Makefile @@ -25,6 +25,7 @@ ORDER := aggression_event_log \ community_membership_update_log \ food_variations \ pantgrunt_event_log \ + subadult_arrivals_log \ tlk_brecord_notes_codes ## diff --git a/db/schemas/housekeeping/indexes/create/subadult_arrivals_log.m4 b/db/schemas/housekeeping/indexes/create/subadult_arrivals_log.m4 new file mode 100644 index 0000000..50fb9f3 --- /dev/null +++ b/db/schemas/housekeeping/indexes/create/subadult_arrivals_log.m4 @@ -0,0 +1,31 @@ +dnl Copyright (C) 2026 The Meme Factory, Inc., http://www.karlpinc.com/ +dnl +dnl This program is free software: you can redistribute it and/or modify +dnl it under the terms of the GNU Affero General Public License as published +dnl by the Free Software Foundation, either version 3 of the License, or +dnl (at your option) any later version. +dnl +dnl This program is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +dnl GNU Affero General Public License for more details. +dnl +dnl You should have received a copy of the GNU Affero General Public License +dnl along with this program. If not, see . +dnl +dnl Karl O. Pinc +dnl +dnl +dnl m4 includes +include(`copyright.m4')dnl +include(`constants.m4')dnl +include(`indexmacros.m4')dnl + +CREATE UNIQUE INDEX IF NOT EXISTS + "On SUBADULT_ARRIVALS_LOG, AnimID must be unique" + ON subadult_arrivals_log + (animid); + +CREATE INDEX IF NOT EXISTS subadult_arrivals_log_firsttikidate + ON subadult_arrivals_log + (firsttikidate); diff --git a/db/schemas/housekeeping/indexes/drop/subadult_arrivals_log.m4 b/db/schemas/housekeeping/indexes/drop/subadult_arrivals_log.m4 new file mode 100644 index 0000000..a96e496 --- /dev/null +++ b/db/schemas/housekeeping/indexes/drop/subadult_arrivals_log.m4 @@ -0,0 +1,26 @@ +dnl Copyright (C) 2026 The Meme Factory, Inc., http://www.karlpinc.com/ +dnl +dnl This program is free software: you can redistribute it and/or modify +dnl it under the terms of the GNU Affero General Public License as published +dnl by the Free Software Foundation, either version 3 of the License, or +dnl (at your option) any later version. +dnl +dnl This program is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +dnl GNU Affero General Public License for more details. +dnl +dnl You should have received a copy of the GNU Affero General Public License +dnl along with this program. If not, see . +dnl +dnl Karl O. Pinc +dnl +dnl +dnl m4 includes +include(`copyright.m4')dnl +include(`constants.m4')dnl +include(`indexmacros.m4')dnl + +DROP INDEX IF EXISTS "On SUBADULT_ARRIVALS_LOG, AnimID must be unique"; + +DROP INDEX IF EXISTS subadult_arrivals_log_firsttikidate; diff --git a/db/schemas/housekeeping/tables/Makefile b/db/schemas/housekeeping/tables/Makefile index 4cdcd54..0fc24d6 100644 --- a/db/schemas/housekeeping/tables/Makefile +++ b/db/schemas/housekeeping/tables/Makefile @@ -26,6 +26,7 @@ ORDER := aggression_event_log \ community_membership_update_log \ food_variations \ pantgrunt_event_log \ + subadult_arrivals_log \ tlk_brecord_notes_codes ## diff --git a/db/schemas/housekeeping/tables/create/subadult_arrivals_log.m4 b/db/schemas/housekeeping/tables/create/subadult_arrivals_log.m4 new file mode 100644 index 0000000..2d914ac --- /dev/null +++ b/db/schemas/housekeeping/tables/create/subadult_arrivals_log.m4 @@ -0,0 +1,34 @@ +dnl Copyright (C) 2026 The Meme Factory, Inc., http://www.karlpinc.com/ +dnl +dnl This program is free software: you can redistribute it and/or modify +dnl it under the terms of the GNU Affero General Public License as published +dnl by the Free Software Foundation, either version 3 of the License, or +dnl (at your option) any later version. +dnl +dnl This program is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +dnl GNU Affero General Public License for more details. +dnl +dnl You should have received a copy of the GNU Affero General Public License +dnl along with this program. If not, see . +dnl +dnl Karl O. Pinc +dnl +dnl +dnl m4 includes +include(`copyright.m4')dnl +include(`constants.m4')dnl +include(`tablemacros.m4')dnl +include(`grants.m4')dnl +dnl + +CREATE TABLE subadult_arrivals_log ( + key_column(`SUBADULT_ARRIVALS_LOG', `ID', INTEGER) + ,animid_column() + ,firsttikidate DATE NOT NULL + ,notes TEXT NOT NULL + notonlyspaces_check(`Notes') +); + +grant_priv(`SUBADULT_ARRIVALS_LOG') diff --git a/db/schemas/lib/triggers/Makefile b/db/schemas/lib/triggers/Makefile index 773dc72..932808a 100644 --- a/db/schemas/lib/triggers/Makefile +++ b/db/schemas/lib/triggers/Makefile @@ -61,7 +61,8 @@ ORDER := comm_ids \ tlk_brecord_notes_codes \ community_membership_update_log \ food_variations \ - pantgrunt_event_log + pantgrunt_event_log \ + subadult_arrivals_log DROP_EXISTING := true diff --git a/db/schemas/lib/triggers/create/subadult_arrivals_log.m4 b/db/schemas/lib/triggers/create/subadult_arrivals_log.m4 new file mode 100644 index 0000000..9961267 --- /dev/null +++ b/db/schemas/lib/triggers/create/subadult_arrivals_log.m4 @@ -0,0 +1,49 @@ +dnl Copyright (C) 2026 The Meme Factory, Inc. http://www.karlpinc.com/ +dnl +dnl This program is free software: you can redistribute it and/or modify it +dnl under the terms of the GNU Affero General Public License as published by +dnl the Free Software Foundation, either version 3 of the License, or +dnl (at your option) any later version. +dnl +dnl This program is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +dnl GNU Affero General Public License for more details. +dnl +dnl You should have received a copy of the GNU Affero General Public License +dnl along with this program. If not, see . +dnl +dnl Triggers for the subadult_arrivals_log table +dnl +dnl Karl O. Pinc + +dnl m4 includes +include(`copyright.m4')dnl +include(`constants.m4')dnl +include(`macros.m4')dnl + + +RAISE INFO 'subadult_arrivals_log_update_func'; +CREATE OR REPLACE FUNCTION subadult_arrivals_log_update_func () + RETURNS trigger + LANGUAGE plpgsql + sdb_function_set_search_path + AS $$ + BEGIN + -- Function for subadult_arrivals_log update trigger + -- + -- AGPL_notice(` --', `2026', + `The Meme Factory, Inc., www.karlpinc.com') + + cannot_change(`SUBADULT_ARRIVALS_LOG', `ID') + + RETURN NULL; + END; +$$; + + +RAISE INFO 'subadult_arrivals_log_update_trigger'; +CREATE TRIGGER subadult_arrivals_log_update_trigger + AFTER INSERT OR UPDATE + ON subadult_arrivals_log FOR EACH ROW + EXECUTE PROCEDURE subadult_arrivals_log_update_func(); diff --git a/db/schemas/lib/triggers/drop/subadult_arrivals_log.m4 b/db/schemas/lib/triggers/drop/subadult_arrivals_log.m4 new file mode 100644 index 0000000..557fe9b --- /dev/null +++ b/db/schemas/lib/triggers/drop/subadult_arrivals_log.m4 @@ -0,0 +1,23 @@ +dnl Copyright (C) 2026 The Meme Factory, Inc. http://www.karlpinc.com/ +dnl +dnl This program is free software: you can redistribute it and/or modify +dnl it under the terms of the GNU Affero General Public License as published by +dnl the Free Software Foundation, either version 3 of the License, or +dnl (at your option) any later version. +dnl +dnl This program is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +dnl GNU Affero General Public License for more details. +dnl +dnl You should have received a copy of the GNU Affero General Public License +dnl along with this program. If not, see . +dnl +dnl Drop triggers for tlk_brecord_notes_codes table +dnl +dnl Karl O. Pinc + +dnl m4 includes +include(`copyright.m4')dnl + +DROP FUNCTION IF EXISTS subadult_arrivals_log_update_func() CASCADE; diff --git a/doc/src/epilog.inc.m4 b/doc/src/epilog.inc.m4 index 8fab327..2a747a1 100644 --- a/doc/src/epilog.inc.m4 +++ b/doc/src/epilog.inc.m4 @@ -814,6 +814,17 @@ elo_ranks_daily_rst(sdb_male, MT)dnl .. |STUDIES.Study| replace:: :ref:`Study ` +.. |SUBADULT_ARRIVALS_LOG| replace:: + :ref:`SUBADULT_ARRIVALS_LOG ` +.. |SUBADULT_ARRIVALS_LOG.ID| replace:: + :ref:`ID ` +.. |SUBADULT_ARRIVALS_LOG.AnimID| replace:: + :ref:`AnimID ` +.. |SUBADULT_ARRIVALS_LOG.FirstTikiDate| replace:: + :ref:`FirstTikiDate ` +.. |SUBADULT_ARRIVALS_LOG.Notes| replace:: + :ref:`Notes ` + .. |SWELLING_SOURCES| replace:: :ref:`SWELLING_SOURCES ` .. |SWELLING_SOURCES.ID| replace:: diff --git a/doc/src/housekeeping.m4 b/doc/src/housekeeping.m4 index ebe9b75..6e04cd7 100644 --- a/doc/src/housekeeping.m4 +++ b/doc/src/housekeeping.m4 @@ -39,4 +39,5 @@ The tables in this section are all in the ``housekeeping`` schema. housekeeping/food_variations.rst housekeeping/community_membership_update_log.rst housekeeping/pantgrunt_event_log.rst + housekeeping/subadult_arrivals_log.rst housekeeping/tlk_brecord_notes_codes.rst diff --git a/doc/src/housekeeping/subadult_arrivals_log.m4 b/doc/src/housekeeping/subadult_arrivals_log.m4 new file mode 100644 index 0000000..a82b361 --- /dev/null +++ b/doc/src/housekeeping/subadult_arrivals_log.m4 @@ -0,0 +1,92 @@ +.. Copyright (C) 2026 The Meme Factory, Inc. www.karlpinc.com + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +.. M4 setup +include(constants.m4)dnl +include(macros.m4)dnl +sdb_rst_quotes(`on')dnl +sdb_generated_rst()dnl + +.. _SUBADULT_ARRIVALS_LOG: + +SUBADULT_ARRIVALS_LOG +--------------------- + +.. |SUBADULT_ARRIVALS_LOG_summary| replace:: + For each chimp that was documented as a subadult at Gombe, this + table describes the procedure used to retroactively add data to + the FOLLOW_ARRIVAL table. + There is, at most, one row per individual. + +|SUBADULT_ARRIVALS_LOG_summary| + + +.. contents:: + :depth: 2 + + +.. _SUBADULT_ARRIVALS_LOG.ID: + +ID (IDentifier) +``````````````` + +.. |SUBADULT_ARRIVALS_LOG.ID_summary| replace:: |idcol| + +|SUBADULT_ARRIVALS_LOG.ID_summary| |notnull| + + +.. _SUBADULT_ARRIVALS_LOG.AnimID: + +AnimID +`````` + +.. |SUBADULT_ARRIVALS_LOG.AnimID_summary| replace:: + The |BIOGRAPHY_DATA|.\ |BIOGRAPHY_DATA.AnimID| that appeared on the + Tiki sheet. + +|SUBADULT_ARRIVALS_LOG.AnimID_summary| +|notnull| + + +.. _SUBADULT_ARRIVALS_LOG.FirstTikiDate: + +FirstTikiDate +````````````` + +.. |SUBADULT_ARRIVALS_LOG.FirstTikiDate_summary| replace:: + The date on which KK chimps were permanently added to the T&G data + sheets. + MT chimps were always put on before age 5. + +|SUBADULT_ARRIVALS_LOG.FirstTikiDate_summary| + +This column may be |null| when there is no information on the date of +permanent addition. + + +.. _SUBADULT_ARRIVALS_LOG.Notes: + +Notes +````` + +.. |SUBADULT_ARRIVALS_LOG.Notes_summary| replace:: + Description of procedure followed to reconstruct arrivals. + ``DATA NOT ENTERED`` indicates that arrivals need to be + reconstructed after database update. + +|SUBADULT_ARRIVALS_LOG.Notes_summary| + +|notonlyspaces| +|notnull| -- 2.34.1